/**
 * XQuery to Scala Translator
 * Fatemeh Borran-Dejnabadi
 * 9 November 2004
 */

package xquery2src;

/** This class provides functionality for printing error messages.
 */
object Report {

    /** Number of errors.
     */
    var errors:int = 0;

    /** Prints out an error message.
     */
    def error(message:String):Unit = {
      errors = errors + 1;
      System.err.println(message);
    }

    /** Prints out an error message.
     */
    def error(position:int, message:String):Unit = {
      errors = errors + 1;
      print(position, message);
    }

    /** Prints out an error message and stops the program execution.
     */
    def fail(message:String):Unit = {
      error(message);
      System.exit(-1);
    }

    /** Prints out an error message and stops the program execution.
     */
    def fail(position:int, message:String):Unit = {
      error(position, message);
      System.exit(-1);
    }

    def print(position:int, message:String):Unit = {
      System.err.println(Position.line(position) + ":" +
                         Position.column(position) + ": " +
                         message);
    }
}
